<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        img{
            width: 300px;
        }
    </style>
</head>
<body>
    
    <img src="../images/1.jpg" alt="" title="早间时间">
    <br>
    <div>上午好！！！</div>

    <script>

        var img = document.querySelector('img');
        var div = document.querySelector('div');

        var date = new Date();
        var h = date.getHours();

        if(h < 12) {
            img.src = '../images/1.jpg';
            img.title = '早间时间';
            div.innerHTML = '上午好！！！';
        }
        else if(h < 18) {
            img.src = '../images/2.jpg';
            img.title = '下午茶时间';
            div.innerHTML = '下午好！！！';
        }
        else{
            img.src = '../images/3.jpg';
            img.title = '晚间时间';
            div.innerHTML = '晚上好！！！';
        }


 
    </script>


</body>
</html>